﻿using RabbitMQ.Client;

namespace Core.RabbitMQ.Producer
{
    public interface IRabbitMqProducer : IRabbitMqRequest
    {

        /// <summary>
        /// 开启事务
        /// </summary>
        /// <returns></returns>
        Task BeginTrans();

        /// <summary>
        /// 提交事务
        /// </summary>
        /// <returns></returns>
        Task CommitTrans();

        /// <summary>
        /// 回滚事务
        /// </summary>
        /// <returns></returns>
        Task RollbackTrans();

        /// <summary>
        /// 异步发送消息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="queueName"></param>
        /// <param name="exchangeName"></param>
        /// <param name="routingKey"></param>
        /// <param name="exchangeType"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        Task PublishAsync(string message, string queueName, string exchangeName = "", string routingKey = "",
            ExchangeTypeEnum exchangeType = ExchangeTypeEnum.Topic,
            IBasicProperties? properties = null);

        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="queueName"></param>
        /// <param name="exchangeName"></param>
        /// <param name="routingKey"></param>
        /// <param name="exchangeType"></param>
        /// <param name="properties"></param>
        void Publish(string message, string queueName, string exchangeName = "", string routingKey = "",
            ExchangeTypeEnum exchangeType = ExchangeTypeEnum.Topic,
            IBasicProperties? properties = null);
    }
}
